package com.jt.demo1;

import com.jt.demo1.config.SpringConfig;
import com.jt.demo1.proxy.JDKProxy;
import com.jt.demo1.service.UserService;
import com.jt.demo1.service.UserServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class TestTx{

    public static void main(String[] args) {
        ApplicationContext context =
                new AnnotationConfigApplicationContext(SpringConfig.class);
        //1.获取目标对象  userServiceImpl 接口UserSesrvice 实现类对象
        UserService target = context.getBean(UserService.class);
        //2.获取代理对象  实现了UserService接口
        UserService proxy = (UserService) JDKProxy.getProxy(target);
        System.out.println("打印代理对象类型:"+proxy.getClass());
        proxy.addUser();
    }
}
